//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    phone: null
  },
  onLoad: function() {
    let that = this;
    app.getToken().then(res => {
      wx.request({
        url: 'https://api.mokyun.com/pesticide/login',
        method: 'POST',
        header: {
          'Accept': 'application/json',
          'Authorization': 'Bearer ' + wx.getStorageSync('token'),
          'content-type': 'application/json',
          'APPID': 32
        },
        success(res) {
          // console.log(res)
          if (res.data.agree == 1) {
            app.globalData.agreement = false
          } else {
            app.globalData.agreement = true
          }
          app.globalData.contactText = res.data.name
          app.globalData.phoneText = res.data.tel
        },

      })
    }).catch(e => {
      wx.redirectTo({
        url: '/pages/authorization/authorization',
      })
    })
  },
  //去往打药界面
  goTask() {
    wx.navigateTo({
      url: '/pages/task/task',
    })
  },
  //去往订单页面
  goOrder() {
    wx.navigateTo({
      url: '/pages/order/order',
    })
  },
  //客服电话
  call() {
    wx.makePhoneCall({
      phoneNumber: '13705145022',
    })
  },
  //去往设置页面
  goSetting() {
    wx.navigateTo({
      url: '/pages/setting/setting',
    })
  }

})